package program;

import program.domain.PCB;
import program.services.FirstComeFirstServed;
import program.services.RoundRobin;
import java.util.ArrayList;
import java.util.Scanner;

/**
 * @program: OSAlgorithms
 * @description: 进程调度主函数
 * @author: Echo-dev
 * @create: 2021-11-25 11:43
 **/
public class ProcessMain {
    public static void main(String[] args) {
        FirstComeFirstServed firstComeFirstServed =new FirstComeFirstServed();
        RoundRobin roundRobin = new RoundRobin();
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<PCB> processes = new ArrayList<>();
        for (int i=0;i<n;i++){
            String pid = scanner.next();
            Integer arriveTime = scanner.nextInt();
            if (i==0){
                firstComeFirstServed.setTime(arriveTime);
            }
            Integer cpuTime = scanner.nextInt();
            PCB pcb = new PCB(pid,arriveTime,cpuTime,"创建");
            processes.add(pcb);
        }
        int scheduleType = Integer.valueOf(scanner.nextLine());
        if (scheduleType==1){
            //FCFS
            firstComeFirstServed.setProcesses(processes);
            firstComeFirstServed.scheduleReady();
            firstComeFirstServed.scheduleRunning();
            firstComeFirstServed.scheduleRunning();
        }
    }

}
